using System;
using Godot;

namespace CSharpLearning.flappy_bird.level;

public enum Operator
{
    Add,
    Sub,
    Mul,
    Div,
}

/// <summary>
/// 数字小鸟里面使用的表达式
/// </summary>
public partial class GameExpression : Resource
{
    [Export]
    public string Expression { get; private set; }

    /// <summary>
    /// 操作符
    /// </summary>
    public Operator Operator { get; private set; }

    /// <summary>
    /// 操作数
    /// </summary>Í
    public int Operand { get;private set; }

    public void Init()
    {
        if (Expression == null)
        {
            Logger.SMsg("GameExpression.Init:NULL");
        }
        Operator = (Operator)Enum.Parse(typeof(Operator), Expression[0].ToString());
        Operand = Convert.ToInt32(Expression[1..]);
    }
}